<?php
/**
 * @package Component Metromap for Joomla! 1.5
 * @version $Id: default_link.php 4 2010-08-17 13:58:48Z batyrkin $
 * @author Batyrkin Anton
 * @copyright (C) 2010- Batyrkin Anton
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/

defined('_JEXEC') or die();
if ($this->defsityid == $this->sityid) {
	$defsityid = true;
}else{
	$defsityid = false;
}
if ($this->tmpl[show_page_title] == 1) {
?>
<table class="contentpaneopen">
<tr>
	<td class="contentheading" width="100%">
	<?php echo $this->tmpl[page_title]; ?></td>
</tr>
</table>
<?php
}
?>
<form action="<?php echo $this->request_url; ?>" method="post" id="MetromapForm" name="MetromapForm">
<div class="metromap">
	<fieldset>
		<table class="metromapform">
		<tr>
			<td valign="top" align="right" class="key">
				<label for="sity">
					<?php echo JText::_( 'Sity' ); ?>:
				</label>
			</td>
			<td>
				<?php echo $this->lists['sityid']; ?>
			</td>

		<?php
		if ($defsityid) {
		?>

			<td width="100" align="right" class="key">
				<label for="stationid">
					<?php echo JText::_( 'Metro Station' ); ?>:
				</label>
			</td>
			<td>
				<?php
					echo $this->lists['stationid'];
				?>
			</td>

		<?php
		}
		?>
		</tr>
	</table>
	</fieldset>

	<?php
	if ($defsityid) {
	echo "<map name=\"metromap\">\n";
	if (!empty($this->item['stations'])) {
		foreach ($this->item['stations'] as $st){
			list($x1,$y1,$x2,$y2) = explode(',',$st->mapcoords);
			echo '<area shape="'.$st->mapshape.'" href="'.$st->stationlink.'" coords="'.$st->mapcoords.'" alt="'.$st->stationname."\">\n";
		}
	}
	echo "</map>\n";
	?>
	<div style="text-align: center;  padding-top: 5px;">
		<img src="/media/com_metromap/map.gif" id="mapimg" alt="<?php echo JText::_( 'Metro Map' ); ?>" usemap="#metromap" />
	</div>
	<?php
	}
	if (!empty($this->item['points'])) {
		echo '<table class="metromapaddr"><tr>';
		if (($this->stationid == 0) AND $defsityid) echo '<th>'.JText::_( 'Station' ).'</th>';
		if ($this->tmpl[show_name] == 1) echo '<th>'.JText::_( 'Name' ).'</th>';
		if ($this->tmpl[show_description] == 1)	echo '<th>'.JText::_( 'Description' ).'</th>';
		if ($this->tmpl[show_address] == 1)	echo '<th>'.JText::_( 'Address' ).'</th>';
		if ($this->tmpl[show_phone] == 1) echo '<th>'.JText::_( 'Phone' ).'</th>';
		echo "</tr>\n";
		foreach ($this->item['points'] as $pt){
			echo '<tr>';
			if (($this->stationid == 0) AND $defsityid) echo '<td>'.$pt->stationname.'</td>';
			if (($this->tmpl[show_link] == 1) AND (!empty($pt->link))) {
				$showlink = true;
			}else{
				$showlink = false;
			}

			if (($this->tmpl[show_name] == 1) AND $showlink)
				echo '<td><a target="_blank" href="'.$pt->link.'">'.$pt->name.'</a></td>';
				else echo '<td>'.$pt->name.'</td>';
			if ($this->tmpl[show_description] == 1) echo '<td>'.$pt->description.'</td>';
			if ($this->tmpl[show_address] == 1) echo '<td>'.$pt->address.'</td>';
			if ($this->tmpl[show_phone] == 1) echo '<td>'.$pt->telephone.'</td>';
			echo '</tr>'."\n";
		}
		echo '</table>';
	}
	?>
</div>
</form>